<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<link rel="stylesheet" href="../resources/js/plugins/layui/css/layui.css"/>
<link rel="stylesheet" href="../resources/css/knowlegPoints.css"/>
<link rel="stylesheet" href="../resources/css/index.css"/>

<div id="Content">
    <div class="btnbar">
        <button type="button" class="import" id="paper_answer_excel">导出答案</button>
        <div class="infotitle" name="paperName">试卷名称：${paperName}</div>
    </div>
    <input type="hidden" name="pid" value=${pid} />
    <table id="answerTable" lay-filter="answerTable" class="treeTable" width="100%" cellpadding="0" cellspacing="0" ></table>
</div>

<script type="text/javascript" src="../resources/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../resources/js/plugins/layui/layui.js"></script>
<script src="../resources/js/fadeInout.js" type="text/javascript"></script>

<script type="text/javascript" language="javascript">

    var pid =  $("input[name='pid']").val();
    var pname =  $("input[name='paperName']").val();

    layui.use('table', function () {
        var table = layui.table;

        table.render({
            elem: '#answerTable',
            url: '/PaperManager/getAnswer?pid='+pid, //数据接口
            //page: true,
            cols: [[
                { field: 'num1', title: '题目序号',width: 80  },
                { field: 'answer1', title: '答案', },
                { field: 'num2', title: '题目序号', width: 80 },
                { field: 'answer2', title: '答案', },
            ],],
            done: function(res, curr, count){
                if(res.msg === "dataError")
                    layer.alert("可能由于题目被删除等情况，导致该试卷被抽查的题目存在异常，请尝试修改试卷，重新生成试卷,或者在试卷题目管理中选择新的题目。", {icon: 2});
            }
        });
    });

    $("#paper_answer_excel").on('click', (e) => {
        location.href = '/PaperManager/exportAnswer?pid=${pid}&pname=${paperName}';
    });

</script>